<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<link th:href="@{/css/shop.css}" type="text/css" rel="stylesheet" />
	<link th:href="@{/css/Sellerber.css}" type="text/css"  rel="stylesheet" />
	<link th:href="@{/css/bkg_ui.css}" type="text/css"  rel="stylesheet" />
	<link th:href="@{/css/pagina.css}" type="text/css"  rel="stylesheet" />
	<link th:href="@{/font/css/font-awesome.min.css}"  rel="stylesheet" type="text/css" />
	<link th:href="@{/layui/css/layui.css}"  rel="stylesheet" type="text/css" />
	<script type="application/javascript" th:src="@{../js/jquery-1.9.1.min.js}"></script>
	<script th:href="@{/js/shopFrame.js}" type="text/javascript"></script>
	<script th:href="@{/js/Sellerber.js}" type="text/javascript"></script>
	<script type="application/javascript" th:src="@{../js/layer/layer.js}"></script>
	<script type="application/javascript" th:src="@{../js/laydate/laydate.js}"></script>
	<script th:src="@{/layui/layui.js}" type="text/javascript"></script>
	<script type="text/javascript" th:href="@{/js/proTree.js}" ></script>
	<title>管理员</title>
</head>
<!--[if lt IE 9]>
<script th:href="@{/js/html5shiv.js}"></script>
<script th:href="@{/js/respond.min.js}"></script>
<script th:href="@{/js/css3-mediaqueries.js}"  type="text/javascript"></script>
<![endif]-->
<body>
<div class="margin Competence_style" id="page_style">
	<div class="operation clearfix">
		<div class="search  clearfix">
			<form id="pageFrm" th:action="@{/role/selectRole}" method="get">
				<span class="submenu"><a th:href="@{/Resource/selectAll}" shiro:hasPermission="user:addResource"  class="btn button_btn bg-deep-blue" title="添加权限"><i class="fa  fa-edit"></i>&nbsp;添加角色权限</a></span>
				<input type="hidden" th:value="${page.totalElements}" id="totalElements"/>
				<input type="hidden" th:value="${page.number}" id="number" name="pageNo"/>
				<input type="hidden" name="pageNo" id="pageNo"/>
			</form>
		</div>
	</div>
	<div class="compete_list">
		<table id="sample-table-1" class="table table_list table_striped table-bordered dataTable no-footer">
			<thead>
			<tr>
				<th>角色id</th>
				<th>角色名称</th>
				<th class="hidden-480">操作</th>
			</tr>
			</thead>
			<tbody>
			<tr th:each="role:${page.content}">
				<td th:text="${role.roleId}"></td>
				<td ><a onclick="userinfo(this)" th:text="${role.roleName}" th:id="${role.roleId}"></a></td>
				<td>
					<a title="新增" th:href="@{/role/addRole}" shiro:hasPermission="user:addRole" class="btn button_btn bg-deep-blue">新增</a>
					<a title="修改" th:href="@{/role/updateRole(roleId=${role.roleId})}" shiro:hasPermission="user:updateRole" class="btn button_btn bg-deep-blue">编辑</a>
				</td>
			</tr>

			</tbody>
		</table>
		<div id="this">
		</div>
		<!--<div id="paging">
            <div class="pagination">
                <lable th:if="${page.number+1}>1">
                    <a class='' title='首页' th:id="0" onclick="page_nav(document.forms[0],this);">首页</a>
                    <a class='' title='上一页' th:id="${page.number}-1"   onclick="page_nav(document.forms[0],this)">上一页</a>
                </lable>
                <lable th:if="${page.number+1}<=1">
                    <button class='disabled' disabled="disabled" title='首页' th:id="0" onclick="page_nav(document.forms[0],this);">首页</button>
                    <button class='disabled' disabled="disabled" title='上一页' th:id="${page.number}-1"   onclick="page_nav(document.forms[0],this)">上一页</button>
                </lable>
                <lable th:each=" i:${#numbers.sequence((page.number)-1,(page.number)+2)}">
                    <lable th:if="${i>=1&&i<=page.totalPages}">
                        <lable th:if="${i==page.number+1}">
                            <span class='current' th:text="${i}" th:id="${i}" onclick="page_nav(document.forms[0],this)"></span>
                        </lable>
                        <lable th:if="${i != page.number+1}">
                            <span th:text="${i}" th:id="${i}" onclick="page_nav(document.forms[0],this)"></span>
                        </lable>
                    </lable>
                </lable>
                <lable th:if="${page.number+1<page.totalPages}">
                    <a  th:id="${page.number}+1" onclick="page_nav(document.forms[0],this);">下一页</a>
                    <a  th:id="${page.totalPages}-1" onclick="page_nav(document.forms[0],this);">尾页</a>
                </lable>
                <lable th:unless="${page.number+1 != page.totalPages}">
                    <button class='disabled' disabled="disabled"  th:id="${page.number}+1" onclick="page_nav(document.forms[0],this);"aria-controls="datatable-responsive" data-dt-idx="1" tabindex="0">下一页</button>
                    <button class='disabled' disabled="disabled"  th:id="${page.totalPages}-1" onclick="page_nav(document.forms[0],this);">尾页</button>
                </lable>
            </div>
        </div>-->
	</div>

</div>
<div class="add_menber" id="add_menber_style" style="display:none">

	<ul class=" page-content">
		<li><label class="label_name">拥有权限：</label><span class="add_name"><input value="" name="拥有权限" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
	</ul>
</div>

<div class="userinfo_style" id="userinfo_style" style="display: none" >

	<div class="member_show" id="userinfo_refresh" th:fragment="userinfo_refresh">

		<div class="member_jbxx clearfix" th:if="${roelDetail!=null}">
			<ul style="text-align: center">
				<li th:each="roelDetail : ${roelDetail}" th:text="${roelDetail.resource.resourcename}" style="display: inline-block;margin: 10px"></li>
			</ul>
			<!--<select>
				<option  th:each="roelDetail : ${roelDetail}" th:value="${roelDetail.resource.resourceid}"  th:text="${roelDetail.resource.resourcename}"></option>
			</select>-->
		</div>
	</div>
</div>
</body>
</html>
<script>
    $(function () {
        pageloddd($("#totalElements").val(),$("#number").val(),1);
    })
    function page_nav(frm,obj){
        frm.pageNo.value =obj.id;
        // alert(obj.id);
        frm.submit();

    };
    /*权限删除*/
    function Competence_del(obj,id){
        layer.confirm('确认要删除吗？',{icon:0,},function(index){
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }
    $('table th input:checkbox').on('click' , function(){
        var that = this;
        $(this).closest('table').find('tr > td:first-child input:checkbox')
            .each(function(){
                this.checked = that.checked;
                $(this).closest('tr').toggleClass('selected');
            });

    });
    function userinfo(obj){
        $.ajaxSettings.async = false;
        layer.open({
            type: 1,
            title: '权限详情',
            maxmin: true,
            shadeClose:false, //点击遮罩关闭层
            area : ['600px' , ''],
            content:$('#userinfo_style')
        });
        $.ajaxSettings.async = true;
        $("#userinfo_refresh").load("/role/selectRoleDetail?roleId="+obj.id);
    }
    /*******滚动条*******/
    $("body").niceScroll({
        cursorcolor:"#888888",
        cursoropacitymax:1,
        touchbehavior:false,
        cursorwidth:"5px",
        cursorborder:"0",
        cursorborderradius:"5px"
    });
    function pageloddd(totalElements,pageNum,pageSize){
        layui.use(['laypage'], function(){
            var laypage = layui.laypage
            //执行一个laypage实例
            var a=0;
            a=a+parseInt(pageNum)+1;
            laypage.render({
                elem: 'this' //注意，这里的 test1 是 ID，不用加 # 号
                ,count: totalElements //数据总数，从服务端得到
                ,curr:a
                ,layout: ['count', 'prev', 'page', 'next', 'skip']
                ,limit:pageSize  //每一页显示的条数
                ,skip:true
                ,jump: function(obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    var aaa=obj.curr-1;
                    if(!first){
                        location.href="/role/selectRole?pageNo="+aaa;
                    }
                }
            });
        });
    }
</script>
